package rsvp.util.referencing;

/**
 * This class is created to be able to pass as reference an integer value
 * @author Kuki Szabolcs @data 2002-01-01
 */
public class IntegerReference
{
    /**
     * The integer value which is passed as reference
     */
    public int intValue = 0;

    /**
     * Contains any additional properties.<br>
     * This class does not make any changes to it.
     * Only the constructor initialize it.
     */
    public Object m_objAditionalProperty = null;

    /**
     * Default constructor intValue = 0;
     */
    public IntegerReference()
    {
        intValue = 0;
    }

    /**
     * When constructed it will initialize the integer value to a user specified value
     * @param inputValue
     */
    public IntegerReference(int inputValue)
    {
        intValue = inputValue;
    }

    /**
     * When constructed with additional property
     * @param inputValue
     * @param objAditionalProperty
     */
    public IntegerReference(int inputValue, Object objAditionalProperty)
    {
        this.intValue = inputValue;
        this.m_objAditionalProperty = objAditionalProperty;
    }

	/**
	 * @param text
	 * @param iDefault default text value
	 * @return
	 */
	public static int parseInt(String text, int iDefault)
	{
		int iRet = iDefault;
		try
		{
			iRet = Integer.parseInt(text);
		} catch (Exception e)
		{
			// keep default value
			iRet = iDefault;
		}
		
		return iRet;
	}
}
